package reflect;

import sun.nio.cs.ext.MacThai;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Person p = new Person();
        p.say("七夕快乐...");
        p.say("喜之郎果冻",5);

        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();
        //say(String info)
        Method m1 = cls.getMethod("say", String.class);//参数类型String.class
        m1.invoke(o,"自己new对象");
        //say(String info,int sum)
        Method m2 = cls.getMethod("say", String.class,int.class);
        m2.invoke(o,"多点关心,多点爱",10);


    }
}
